package com.help10000.rms.ui.activitys

import android.os.Bundle

import android.view.View
import com.amir.common.mvp.presenter.BasePresenter
import com.amir.common.mvp.view.IView
import com.amir.common.weight.DuplicateClickProxy
import com.help10000.rms.R
import com.help10000.rms.ui.base.BaseActivity
import com.help10000.rms.ui.utils.PageUtils
import kotlinx.android.synthetic.main.activity_result.*

/**
 * 结果页
 */
class ResultActivity : BaseActivity<BasePresenter<IView>, IView>(), View.OnClickListener {


    override fun getlayoutId(): Int {
        return R.layout.activity_result
    }

    var cls: Class<*>? = null
    override fun initView() {
        confirm_button.setOnClickListener(DuplicateClickProxy(this))
        titleBar.setOnLeftClickListener {
            PageUtils.jumpToActivity(this, cls as Class<*>)
        }
    }

  override fun initData(savedInstanceState: Bundle?){
        cls = intent.getSerializableExtra("cls") as Class<*>
        var result = intent.getBooleanExtra("result", false)
        var content = intent.getStringExtra("content")
        stateImageView.setImageResource(if (result) R.drawable.success else R.drawable.error)
        resultTitle.text = (if (result) "操作成功" else "操作失败")
        stateTextView.text = content

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.confirm_button -> {
                PageUtils.jumpToActivity(this, cls as Class<*>)
                finish()
            }
        }
    }
}